/**
 *******************************************************************************
 * \brief   CAS EBX Project Work "Kaffeemaschine"
 *
 * \file    createPool.c
 * \version 1.0
 * \date    11.07.2010
 * \author  Baehler Thomas, Liechti Beat, Sauter Marc
 * \author  Vuksic Valentina, Zbinden Rene
 * 
 * \details	creates pool
 * \details build with: 
 * \details gcc pool.c createPool.c -o createPool -lrt
 * \details then run with (example):
 * \details createPool <chname:string>
 *
 * \remark  Last Modifications:
 * \remark  V1.0, 11.07.2010   Initial release
 *******************************************************************************
 **/

#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// -- required for inet_aton when not using makefile???
//#define __USE_MISC

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
//#include <sys/sendfile.h>
#include <sys/wait.h>
#include <time.h>
#include <sys/times.h>
#include <sched.h>

#include "pool.h"

#define RETCODE_SUCCESS		0
#define RETCODE_ERROR		-1

void usage(char *progname)
{
	printf("usage:\n\t%s <name of channel>\n", progname);
}

int main(int argc, char** argv)
{
	int retCode = -1;
	if (argc == 2)
	{
		// -- expecting a string argv[1]
		char *poolName = argv[1];
		int initData = 0;
		int create = createPool(poolName, &initData, sizeof(int));
		if (create != 0)
		{
			printf("ERROR: could not create pool %s, createPool returned %d , aborting\n", poolName, create);
		}
		else
		{
			printf("created pool %s\n", poolName);
			retCode = 0;
		}
	}
	else
	{
		usage(argv[0]);
	}
	return retCode;
}
